<template>
  <view class="page">

    <view class="assess-page">
      <view style="padding: 12px" v-if="detailInfo.length > 0 && detailInfo[0].companyName">
        <!-- 企业名称 -->
        <view class="top-title">
          <img class="top-img" src="@/static/market/levelAssessTitle.png" />
          <span class="top-text">{{ detailInfo[0].companyName }}</span>
        </view>
        <!-- 历史信用评定详情区域 -->
        <view class="content-list">
          <me-table :i="0" :top="0" class="main-content" style="padding-bottom:90px;" :index="0" :load-data="loadData" :init-load="true" ref="mescrollItem0">
            <view class="re-list" slot-scope="d">
              <view class="re-content">
                <view class="re-icon">
                  <u-row style="width: 100%">
                    <u-col span="6">
                      信用评定人:{{d.data.operatorName}}
                    </u-col>
                    <u-col span="6">
                      评定时间:{{d.data.manualDate}}
                    </u-col>
                  </u-row>
                </view>
                <view class="re-icon">
                  <u-row style="width: 100%">
                    <u-col span="12">
                      评定说明：{{d.data.remark}}
                    </u-col>
                  </u-row>
                </view>
                <view class="re-icon">
                  <u-row style="width: 100%">
                    <u-col span="4" style="padding-left: 0px">
                      <u-icon :label="d.data.creditInspireMainItem[0].targetTypeName||'' " size="30" name="/static/check/round-nfc.png"></u-icon>
                    </u-col>
                    <u-col span="8">
                      <u-icon :label="d.data.creditInspireMainItem[0].targetName||'' " size="30" name="/static/check/round-checkin.png"></u-icon>
                    </u-col>
                  </u-row>
                </view>
                <view class="re-icon">
                  <u-row style="width: 100%;display:flex;flex-direction: column;align-items: flex-start;">
                    <view :index="j" v-for="(cell,j) in d.data.creditInspireMainItem" :key="cell.key" style="line-height: 42rpx;display:block;">{{j+1}}.{{cell.standardName}}</view>
                  </u-row>
                </view>
                <view class="re-icon">
                  <u-row style="width: 100%">
                    <u-col span="4" style="padding-left: 0px">
                      <view style="color:#2980e3" @click="clickGoFile(d.data.inspireMainUuid,'xc')">现场图片信息</view>
                    </u-col>
                    <u-col span="8">
                      <view style="color:#2980e3" @click="clickGoFile(d.data.inspireMainUuid,'zm')">评定证明图片信息</view>
                    </u-col>
                  </u-row>
                </view>
              </view>
            </view>
          </me-table>
        </view>
      </view>
      <view v-else class="card card-content" style="display:flex;justify-content:center;padding: 12px">暂无数据~</view>
    </view>
    <!-- 查看图片 -->
    <u-popup mode="bottom" height="80%" v-model="GoFileShow" :closeable="true">
      <view class="zk-img-content"  v-if="flag=='xc'">
        <m-upload :deletable="false" :maxCount="picIds" width="150rpx" height="150rpx" :file-list="liveFileList" :multiple="true" :disabled="true" index="liveFile"
          :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.m_check_attr, }" upApiUrl="uploadBase64ForApp" ref="filePicUpload"></m-upload>
      </view>
      <view class="zk-img-content" v-else>
        <m-upload :deletable="false" :maxCount="picIds" width="150rpx" height="150rpx" :file-list="liveFileList1" :multiple="true" :disabled="true" index="liveFile"
          :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.m_check_attr, }" upApiUrl="uploadBase64ForApp" ref="filePicUpload"></m-upload>
      </view>
      <!-- <view class="zk-img-content" v-if="liveFileList.length">
        <swiper :style="{ 'height': height + 'px','width': width + 'px' }" :indicator-dots="true" indicator-color="rgba(0,0,0,0.3)" indicator-active-color="#2979FF" :autoplay="false"
          :interval="interval" :duration="duration" @change="swiperChange">
          <view v-for="(item,index) in liveFileList" :key="index">
            <swiper-item :scroll-top="0" :style="{ height: getScrollHeight() }" :scroll-y="true" :scroll-x="false" class="scroll-Y table-body">
              <image class="m-preview-image" :src="getAkAppendImg(item)"></image>
            </swiper-item>
          </view>
        </swiper>
      </view>
      <view v-else class="no-file">暂未上传图片，请至电脑端上传！</view> -->

    </u-popup>
  </view>
</template>

<script>
import mUpload from "@/components/m-upload.vue";
import MeTable from "@/components/me-table.vue";
import moment from "moment";
import checkService from "@/service/check/check.service.js";
import intelligenceservice from "@/service/intelligence/intelligence.service";
import { PATHROOT } from "@/common/path.config";

export default {
  components: {
    MeTable,
    mUpload
  },
  onLoad(opt) {
    // this.retailerUuid = opt.retailerUuid
    // console.log(this.retailerUuid)
  },
  props: {
    retailerUuid: {
      type: String,
      default: ""
    },
    licNo: {
      type: String,
      default: ""
    }
  },
  mounted() {
    this.loadData({ num: "1", size: "10" });
    // this.fileViewUrl += "?tk=" + this.user.tk + "&fileId=";
  },
  data() {
    return {
      // user: this.$store.state.userInfo,
      // fileViewUrl: PATHROOT.BASE + "/commonfile/filestore/downloadFile.do",
      // // height: this.$u.sys().windowHeight - 70,
      // height: 310,
      // width: this.$u.sys().windowWidth,
      // interval: 5000,
      // duration: 500,
      GoFileShow: false,
      picIds: 3,
      liveFileList: [], // 现场文件列表
      liveFileList1:[],
      moment,
      flag:'',
      detailInfo: [
        {
          companyName: "" // 企业名称
        }
      ]
    };
  },
  methods: {
    loadData(page) {
      let param = {
        licNo: this.licNo,
        page: page.num,
        limit: page.size,
        inspireStatus :'02'
      };
      // return checkService
      //   .queryCreditInspireList(param);
      return new Promise(resolve => {
        checkService
          .queryCreditInspireList(param)
          .then(res => {
            if (res.success) {
              this.detailInfo = res.data;
              resolve({
                count: res.count,
                data: res.data
              });
            } else {
              resolve({
                count: 0,
                data: []
              });
            }
          })
          .catch(e => {
            resolve({
              count: 0,
              data: []
            });
          });
        // });
      });
    },
    clickGoFile(inspireMainUuid, flag) {
      this.flag=flag
      this.GoFileShow = true;
      this.liveFileList = [];
      let params = {
        bizId: inspireMainUuid,
        group: this.$FILE_GROUP_TYPE.m_check_attr,
        menuCode: null
      };
      intelligenceservice.findFilesByBizIdAndGroup(params).then(resfile => {
        if (resfile.success) {
          // 对请求回的附件分组

          resfile.data?.forEach(list => {
            // if (flag == "xc") {
              if (list.gfiStoreName.includes("assessDesc_")) {
                this.liveFileList.push(list); // 现场文件列表
              }
             else {
              // if (!list.gfiStoreName.includes("assessDesc_")) {
               this.liveFileList1.push(list); // 评定证明图片列表
              // }
              
            }
          });
        }
      });
    },
    getAkAppendImg(item) {
      console.log("数据" + JSON.stringify(item));
      if (item.gfUrl) {
        return item.gfUrl;
      }
      return this.fileViewUrl + item.gfiId;
    },
    // swiperChange() {
    //   //   this.current = e.detail.current;
    // },
    // getScrollHeight() {
    //   let p = this.height - uni.upx2px(80) + "px";
    //   // #ifdef H5-WECHAT
    //   p = this.height + "px";
    //   // #endif
    //   return p;
    // }
  }
};
</script>

<style lang="scss" scoped>
.page {
  padding: 0;
  .top-title {
    display: flex;
    justify-content: center;
    align-items: center;
    .top-img {
      width: 32px;
      height: 32px;
    }
    .top-text {
      font-size: 38rpx;
      font-weight: 700;
      margin-left: 15px;
      color: #2980e3;
    }
  }
  .content-list {
    //   background-color: #f3f4f5;
  }

  .re-list {
    margin: 20rpx 0;
    color: #666666;
    font-size: 15px;
    border: 1px solid #e9e9e9;
    box-shadow: 0px 1px 5px #d9d6d6;
    //   display: flex;
    //   flex-direction: row;
    //   justify-content: flex-start;
    //   -webkit-flex-direction: row;
    background-color: #fff;
    border-radius: 12px;
    padding: 12px;
  }
  .re-content {
    width: 100%;

    .re-manager {
      display: flex;
      justify-content: space-between;

      .re-title {
        width: calc(90%);
        font-size: 15px;
        color: #666;
        font-weight: 600;
        margin-bottom: 5px;
        width: 80%;
      }
    }

    .re-subtitle {
      padding-top: 5px;
      color: #666;
    }

    .re-icon {
      display: flex;
      padding-top: 10px;
    }
  }
}
.m-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10rpx;
}
.zk-img-content {
  display: flex;
  justify-content: center;
}
// .cell-txt {
//         line-height: 32rpx;
//       }
.w-28 {
  width: 28%;
}
.w-34 {
  width: 34%;
}
.w-40 {
  width: 40%;
}
.flex {
  display: flex;
}
.jc-sb {
  justify-content: space-between;
}
.ai-c {
  align-items: center;
}
.ml-16 {
  margin-left: 34rpx;
}
</style>